package com.ky.home.controller;


import com.ky.common.vo.R;
import com.ky.home.entity.Yearquestions;
import com.ky.home.mapper.YearquestionsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 历年真题库 前端控制器
 * </p>
 *
 * @author pl
 * @since 2024-06-22
 */
@RestController
@RequestMapping("/home")
public class YearquestionsController {

    @Autowired
    private YearquestionsMapper yearquestionsMapper;
    @RequestMapping("/yearquestions")
    public R getYearquestions(){
        return R.ok(yearquestionsMapper.selectList(null));
    }
    @RequestMapping("/searchYearQuestion/{yearId}")
    public R searchYearquestions(@PathVariable("yearId")int yearId){
        Yearquestions yearquestions = yearquestionsMapper.selectById(yearId);
        if (yearquestions != null){
            return R.ok(yearquestions);
        }
       return R.fail("查询失败");
    }

}

